package com.mijie.homi.dao.commom;

import java.util.HashMap;

import org.springframework.stereotype.Repository;

import com.mijie.core.IBatisDao;
import com.mijie.homi.common.domain.Integration;

@Repository
public class IntegrationDao extends IBatisDao {

	
	public Integration getIntegrationById(int id){
		return this.selectOne("getIntegrationById", id);
	}
	
	public boolean haveReward(int id,int actionId){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", id);
		parameter.put("actionId", actionId);
		return this.selectOne("haveReward", parameter)!=null;
	}
	
	public Integer getTodayIntegralReward(int userId,int actionId){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", userId);
		parameter.put("actionId", actionId);
		return this.selectInteger("getTodayIntegralReward", parameter);
	}
	
	
	public int updateIntegralRewardDetail(int userId,int actionId,int integral){
		HashMap<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("userId", userId);
		parameter.put("actionId", actionId);
		parameter.put("integral", integral);
		return this.update("updateIntegralRewardDetail", parameter);
	}

}
